#include<iostream>
using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		int n;
		cin >> n;
		double sum = 0,aver;
		double* arr = new double[n];
		for (int j = 0; j < n; j++)
		{
			cin >> arr[j];
			sum += arr[j];
		}
		aver = sum * 1.0 / n;
		int count = 0;
		for (int j = 0; j < n; j++)
		{
			if (arr[j] > aver)
			{
				count++;
			}
		}
		cout << count << endl;
		delete[] arr;
	}

	return 0;
}